﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.AnalysisServices;
using Moop.Common.IFaces;
using Microsoft.Practices.Unity;

namespace Moop.DataLayer.Olap
{
    public class OlapServer : IOlapServer
    {
        public string ServerName { get; set; }
        public string ConnectionString { get; set; }   
        public Server Server { get; set; }

        public OlapServer()
        {
            Server = new Server();
        }

        [InjectionConstructor]
        public OlapServer(string connectionString)
        {
            ConnectionString = connectionString;            
            try
            {
                Server.Connect(connectionString);
            }
            catch (AmoException e)
            {
                Console.WriteLine("AMO exception " + e.ToString());
                Server = null;
            }
            catch (Exception e)
            {
                Console.WriteLine("General exception " + e.ToString());
                Server = null;
            }
        }



    }
}
